﻿using DotNetCore.CAP;
using Framework.ExtensionsMods.Quartz.Model;
using Framework.ExtensionsMods.Quartz.Server.IServer;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;

namespace Framework.ExtensionsMods.Test.Controllers
{
	[ApiController]
	[Route("[controller]")]
	public class JobTasksController : ControllerBase
	{
		private readonly ITaskSchedulerServer _taskSchedulerServer;
		public JobTasksController(ITaskSchedulerServer taskSchedulerServer)
		{
			_taskSchedulerServer = taskSchedulerServer;
		}

        [HttpGet]
		[Route("AddTaskSchedule")]
		public async Task<ApiResult> AddTaskSchedule()
		{
			SysTasks tasksQz = new SysTasks();
			tasksQz.ID = "1649960254726868992";
			tasksQz.Name = "Job_SyncTest";
			tasksQz.AssemblyName = "Framework.ExtensionsMods.Test";
			tasksQz.ClassName = "Quartz.Job_SyncTest";
			tasksQz.RunTimes = 7;
            tasksQz.JobGroup = "SYSTEM";
			tasksQz.TriggerType = 0;
			tasksQz.IntervalSecond = 10;
			tasksQz.IsStart  = true;
			tasksQz.TaskType = 1;
			tasksQz.BeginTime = DateTime.Now;
			tasksQz.EndTime = DateTime.Now.AddDays(1);
			return await _taskSchedulerServer.AddTaskScheduleAsync(tasksQz);
		}
	}
}
